<?php

class ShopController extends Controller {
	
	public $layout='//layouts/column2';
	
	public function actionIndex() {
		echo 'hihi';
	}
	
	public function actionForm($id=null) {
		$model= new ShopComponent();
		if ($id && !($model = ShopComponent::model()->findByPk($id))) {
		    $this->redirect(Yii::app()->baseUrl.'/shop/');
        }
		
		$citylist = array('Ha Noi','Ho Chi Minh');
		$catlist = array('Thoi trang','Dien may');
		
		$this->render('form', array('model'=>$model,'citylist'=>$citylist, 'catlist'=>$catlist));
	}
	
	public function actionCreate() {
		$model = new ShopComponent();
		
		if (isset($_POST["ShopComponent"])) {
			// assign value to model
			$model->attributes=$_POST['ShopComponent'];
			
			//$model->validate();
			//var_dump($model->getErrors());
			
			
	        if($model->save())
	            $this->redirect('index');
			else var_dump( $model->getErrors() );
			
		} 
	}
}
